import React, { Component, PureComponent } from 'react'

//引入connect用于连接UI组件与redux
import { connect } from 'react-redux'

import { Button } from 'antd';

//定义UI组件
class AuthButton extends PureComponent {

  render() {

    const { buttonPermissionList, dispatch, permission = null, size='small', ...rest} = this.props

    if(!permission){
      return <Button {...rest} size={size} />
    }

    return buttonPermissionList.includes(permission) ? <Button {...rest} onClick={this.test} /> : null

  }
}

//使用connect()()创建并暴露一个 AuthButton 的容器组件
export default connect(
  state => ({
    buttonPermissionList: state.buttonPermissionList
  })
)(AuthButton)
